package com.gasstation

import java.util.Date

class InventoryRegular {
	Date transactionOn
	double regularOpenGallons
	double regularOpenInvCost
	double regularPurchasedGallons
	double regularPurchasedCost
	double regularSaleGallons
	double regularCost
	double regularCloseGallons
	double regularActualGallons
	double regularVariance
	double regularAvgCost

	// Automatically updated by GORM
	Date dateCreated
	// Automatically updated by GORM
	Date lastUpdated
	static mapping = { sort transactionOn:"asc" }
	static constraints = { transactionOn unique: true }
	void calculateRegularCloseGallons(){
		regularCloseGallons = regularOpenGallons+regularPurchasedGallons-regularSaleGallons
	}
	void calculateRegularAvgCost(){
		regularAvgCost = (regularOpenInvCost+regularPurchasedCost)/(regularOpenGallons+regularPurchasedGallons)
	}
	void calculateRegularCost(){
		regularCost = regularSaleGallons*regularAvgCost
	}
	void calculateRegularVariance(){
		regularVariance = regularActualGallons - regularCloseGallons
	}
}
